package Model;

import java.sql.*;

public class BancodeDados {

	private ResultSet rs;
	private Statement st;
	private Connection con;
	private Statement s;

	public BancodeDados() {
		try {
			Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
			con = DriverManager.getConnection("jdbc:sqlserver://localhost:1433;databaseName=trabalhos;user=Admin;password=trabalho123");
			s = con.createStatement();
			con.setAutoCommit(false);
			System.out.println("BD Conectado");
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	public boolean InUpDelBanco(String sql) throws SQLException {
		try {
			st.executeUpdate(sql);
			con.commit();
			return true;
		} catch (Exception e) {
			e.printStackTrace();
			con.rollback();
			return false;
		}
	}
	/* errado-- fazer um pra cada classe
	public ResultSet select(String par)  throws SQLException{
		try {
			rs = st.executeQuery(par);
			st.close();
			return rs;
		} catch (Exception e) {
			con.rollback();
			e.printStackTrace();
			return null;
		}
	}
	/*
	public ArrayList<ResultSet> select(String par) {
		ArrayList<ResultSet> resut=new ArrayList<ResultSet>();
		try {
			pst = con.prepareStatement(par);
			rs = pst.executeQuery();
			
			rs.close();
			pst.close();
			return rs;
		} catch (Exception e) {
			e.printStackTrace();
			return null;
		}
	}*/
}